package com.springcloudalibaba.rabbitmq;

import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.apache.rocketmq.spring.support.RocketMQHeaders;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: TongRui乀
 * @Date: 2019-12-09 15:58
 * @description：
 */
@RestController
@RequestMapping("mq")
public class ProducerService {

    @Autowired
    private RocketMQTemplate rocketMQTemplate;

    @GetMapping("send/{message}")
    public String send(@PathVariable String message){

        this.rocketMQTemplate.send("test_topic", MessageBuilder.withPayload(message)
                .setHeader(RocketMQHeaders.TAGS,"binder").build());

        return "SUCCESS";
    }
}
